import NotFound from './components/404.vue';
import isInIcestark from '@ice/stark-app/lib/isInIcestark';
import renderNotFound from '@ice/stark-app/lib/renderNotFound';


const renderNotFoundPromise = () => new Promise((resolve) => {
  renderNotFound();
  resolve(true);
});

const modules = import.meta.glob('./router/**/*.ts');



const routes = [
  {
    path: "/",
    redirect: "/vehicle",
  },
  {
    path: "/index", // layout
    name: "index",
    component: () => import("@/pages/index.vue"),
    children: [

    ]
  },
  {
    path: '/:pathMatch(.*)',
    component: isInIcestark() ? () => renderNotFoundPromise() : NotFound,
  },
];
// 加入到路由集合中
for(const mo in modules){
 await modules[mo]().then(mod =>{
      // @ts-ignore
   routes[1].children.push(...mod.default)
  })
}

export default routes;
